package Echart

import (
	"WebSvr/modules/common"
)

type S2CBaseJson struct {
	Title    `json:"title"`
	Tooltip  `json:"tooltip"`
	Legond   `json:"legend"`
	Toolbox  `json:"toolbox"`
	DataZoom []DataZoom_sub `json:"dataZoom"`
}

type Title struct {
	Text    string `json:"text"`
	Subtext string `json:"subtext"`
	X       string `json:"x"`
}

type Tooltip struct {
	Trigger     string `json:"trigger"`
	AxisPointer `json:"axisPointer"`
}

type AxisPointer struct {
	Animation bool `json:"animation"`
}

type Legond struct {
	Data []string `json:"data"`
	X    string   `json:"x"`
}

type Toolbox struct {
	Show    bool `json:"show"`
	Feature `json:"feature"`
}

type Feature struct {
	DataZoom    `json:"dataZoom"`
	Mark        `json:"mark"`
	DataView    `json:"dataView"`
	MagicType   `json:"magicType"`
	Restore     `json:"restore"`
	SaveAsImage `json:"saveAsImage"`
}

type Mark struct {
	Show bool `json:"show"`
}

type DataZoom struct {
	YAxisIndex string `json:"yAxisIndex"`
}

type DataView struct {
	Show     bool `json:"show"`
	ReadOnly bool `json:"readOnly"`
}

type MagicType struct {
	Show bool     `json:"show"`
	Type []string `json:"type"`
}

type Restore struct {
	Show bool `json:"show"`
}

type SaveAsImage struct {
	Show bool `json:"show"`
}

type DataZoom_sub struct {
	Type       string `json:"type"`
	Show       bool   `json:"show"`
	Realtime   bool   `json:"realtime"`
	Start      int32  `json:"start"`
	End        int32  `json:"end"`
	XAxisIndex int32  `json:"xAxisIndex"`
}

type GetS2CMsger interface {
	getS2CData(pC2Sjson *common.C2SJson, table string) error
	setTitleText(text string, subText string, pos string)
	setToolTip(trigger string, bAnimation bool)
	setToolbox()
}

func (s2cBase *S2CBaseJson) setTitleText(text string, subText string, pos string) {
	s2cBase.Title.Text = text
	s2cBase.Title.Subtext = subText
	s2cBase.Title.X = pos
}

func (s2cBase *S2CBaseJson) setToolTip(trigger string, bAnimation bool) {
	s2cBase.Tooltip.Trigger = trigger
	s2cBase.Tooltip.AxisPointer.Animation = bAnimation
}

func (s2cBase *S2CBaseJson) setToolbox() {
	s2cBase.Toolbox.Show = true
	s2cBase.Toolbox.Feature.DataZoom.YAxisIndex = "none"
	s2cBase.Toolbox.Mark.Show = true
	s2cBase.Toolbox.DataView.Show = true
	s2cBase.Toolbox.DataView.ReadOnly = true
	s2cBase.Toolbox.MagicType.Show = true
	s2cBase.Toolbox.MagicType.Type = []string{"line", "bar"}
	s2cBase.Toolbox.Restore.Show = true
	s2cBase.Toolbox.SaveAsImage.Show = true
}
